﻿namespace HySoft.Cash.Business
{
    using Huayou.Common.Database;
    using Huayou.Utils;
    using HySoft.Cash.BaseClass;
    using HySoft.Cash.DB;
    using HySoft.Cash.Structure;
    using System;
    using System.Data;
    using System.Web.UI;

    public class TinvoicelistBN : BaseBusiness
    {
        private TinvoicelistDB db;

        public TinvoicelistBN(Page page) : base(page)
        {
            this.db = null;
            this.db = new TinvoicelistDB(base.curDBOperater);
        }

        public TinvoicelistBN(Page page, DBOperate oper) : base(page, oper)
        {
            this.db = null;
            this.db = new TinvoicelistDB(base.curDBOperater);
        }

        public bool Add(TinvoicelistDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Add(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public bool Delete(int Sid)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Delete(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public void Dispose()
        {
            base.Dispose();
            if (this.db != null)
            {
                this.db = null;
            }
        }

        public bool Edit(TinvoicelistDT detail)
        {
            bool flag = false;
            try
            {
                try
                {
                    flag = this.db.Edit(detail);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return flag;
        }

        public TinvoicelistDT Get(int Sid)
        {
            TinvoicelistDT tdt = null;
            try
            {
                try
                {
                    tdt = this.db.Get(Sid);
                }
                catch (Exception exception)
                {
                    throw exception;
                }
            }
            finally
            {
            }
            return tdt;
        }

        public DataTable GetList()
        {
            base.DBFieldList = "Sid,OrgSid,InvoiceDate,InvoiceAmount,IsValid,ReceiveAmount,Note,Penalty,InterestCharges,PaymentDate,Guid";
            base.DBTable = "tInvoiceList";
            return base.CommonGetList();
        }

        public void QueryGuid(string Guid)
        {
            if ((Guid != null) && (Guid.Trim() != ""))
            {
                base.Filter = "Guid like '%" + StringUtils.ToSQL(Guid) + "%'";
            }
        }

        public void QueryInterestCharges(string InterestCharges)
        {
            if ((InterestCharges != null) && (InterestCharges.Trim() != ""))
            {
                base.Filter = "InterestCharges like '%" + StringUtils.ToSQL(InterestCharges) + "%'";
            }
        }

        public void QueryInvoiceAmount(string InvoiceAmount)
        {
            if ((InvoiceAmount != null) && (InvoiceAmount.Trim() != ""))
            {
                base.Filter = "InvoiceAmount like '%" + StringUtils.ToSQL(InvoiceAmount) + "%'";
            }
        }

        public void QueryInvoiceDate(string InvoiceDate)
        {
            if ((InvoiceDate != null) && (InvoiceDate.Trim() != ""))
            {
                base.Filter = "InvoiceDate like '%" + StringUtils.ToSQL(InvoiceDate) + "%'";
            }
        }

        public void QueryIsValid(int IsValid)
        {
            base.Filter = "IsValid= " + IsValid;
        }

        public void QueryNote(string Note)
        {
            if ((Note != null) && (Note.Trim() != ""))
            {
                base.Filter = "Note like '%" + StringUtils.ToSQL(Note) + "%'";
            }
        }

        public void QueryOrgSid(int OrgSid)
        {
            base.Filter = "OrgSid= " + OrgSid;
        }

        public void QueryPaymentDate(string PaymentDate)
        {
            if ((PaymentDate != null) && (PaymentDate.Trim() != ""))
            {
                base.Filter = "PaymentDate like '%" + StringUtils.ToSQL(PaymentDate) + "%'";
            }
        }

        public void QueryPenalty(string Penalty)
        {
            if ((Penalty != null) && (Penalty.Trim() != ""))
            {
                base.Filter = "Penalty like '%" + StringUtils.ToSQL(Penalty) + "%'";
            }
        }

        public void QueryReceiveAmount(string ReceiveAmount)
        {
            if ((ReceiveAmount != null) && (ReceiveAmount.Trim() != ""))
            {
                base.Filter = "ReceiveAmount like '%" + StringUtils.ToSQL(ReceiveAmount) + "%'";
            }
        }

        public void QuerySid(int Sid)
        {
            base.Filter = "Sid= " + Sid;
        }
    }
}

